<?php

namespace App\Service;

use App\Core\Rpc\Client;
use App\Model\AreaModel;

/**
 *  配置信息
 * @author lihaiping
 */
class ConfigService extends Client
{
    /**
     * 定义对应服务提供者的服务名称
     * @var string
     */
    protected $serviceName = 'CommonService';

    /**
     * 定义对应服务提供者的服务协议
     * @var string
     */
    protected $protocol = 'jsonrpc-http';

    /**
     * The load balancer of the client, this name of the load balancer
     * needs to register into \Hyperf\LoadBalancer\LoadBalancerManager.
     *
     * @var string
     */
    protected $loadBalancer = 'random';

    /**
     * 获取配置信息
     * @param int $companyId
     * @param array $keys
     * @return array
     */
    public function get(int $companyId, array $keys): array
    {
        if ( ! $keys) {
            return [];
        }
        return $this->__request(__FUNCTION__, compact('companyId', 'keys'));
    }

    /**
     * 初始化配置信息
     * @param int $companyId
     * @return array
     */
    public function init(int $companyId): array
    {
        return $this->__request(__FUNCTION__, compact('companyId'));
    }

    /**
     * 初始化配置信息
     * @param int $companyId
     * @param array $param
     * @return bool
     */
    public function save(int $companyId, array $param): bool
    {
        return $this->__request(__FUNCTION__, compact('companyId', 'param'));
    }

}
